package com.kt.dao;

import com.kt.po.User;
import com.kt.sqlProvider.MapperSqlProvider;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface UserMapper {
    @Select("select * from userinfo where username=#{username}")
    List<User> findUserByNameMap(@Param("username") String username);

    @Insert("INSERT INTO userinfo (username,password,gxqm,date) " +
            "VALUES (#{username},#{password},#{gxqm},#{date})")
    @Options(useGeneratedKeys=true, keyProperty="id", keyColumn="id")//反填user,servive可获取自增的userid,useGeneratedKeys=true为使用生成键
    void addUserMap(User user);

    @Delete("DELETE from userinfo WHERE id=#{id}")
    int deleteUserMap(@Param("id") int id);

    @Select("SELECT * FROM userinfo LIMIT #{page},#{size}")
    List<User> findUserPageMap(Map<String,Object> map);

    @SelectProvider(type = MapperSqlProvider.class,method = "selectUserWithParam")
    List<User> selectUserWithParam(Map<String,Object> map);
}
